<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
	
	<table class="layui-hide" id="leave" lay-filter="leave"></table>
	<script type="text/html" id="toolbarDemo">
			<a name="fixbar">请假记录</a>
	</script>
	<script type="text/javascript">
		var option={
			elem:'#leave',
			title:'数据字典',
			path:'askForleave',
			addurl:'edit',
			toolbar:'#toolbarDemo',
			cols: [[
				{field: 'startDate',align:'center', title: '开始时间'},
				{field: 'endDate',align:'center', title: '结束时间'},
				{field: 'type', title: '请假类型',align:'center',width:130},
				{field: 'reasonforleave', title: '请假原因'},
				{field: 'endDate',align:'center', title: '请假条证明' ,templet: function(d){
					return d.leavefile==null?"无图片":'<a class="layui-btn layui-btn-xs layui-btn-primary layui-icon layui-icon-rate-solid" data-method="notice" lay-event="leaves"> 查看</a>';
				}},
				{field: 'state', title: '请假状态' ,templet: function(d){
					
					var sum = "" ;
					if(d.state == 1){
						sum = "待审核";
					}else if(d.state == 2){
						sum = "同意申请";
					}else if(d.state == 3){
						sum = "已拒绝";
					}else{
						sum = "待处理";
					}
					return sum;
				}},
				{field: 'reason', title: '处理原因'},
			]] 
		}
		var currRow='${param.currRow==null?null:param.currRow}';
		var limit=${param.limit==null?'null':param.limit};
		var page=${param.page==null?'null':param.page};
		var classTable=new LayUiTable(option,currRow,limit,page);
		classTable.init();
		
		
		layui.use('table', function(){
			var table = layui.table;
			table.on('tool(leave)', function(obj){
			    var data = obj.data;
			    if(obj.event === 'leaves'){
			    	layer.open({
			    		  title: '请假条'
			    		  ,shadeClose:true
			    		  ,content: '<img alt="" src="download?uuid='+obj.data.leavefile+'" style="width: 100%;">'
			    	});   
			    	console.info(obj);
			    }
			});
		});
	</script>
</html>